package com.seven.service;

import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.concurrent.TimeUnit;

/**
 * @Author seven
 * @Date 2020/5/9 15:45
 **/
@Service
public class ScheduledService {

    /**
     *
     * @return
     * @Scheduled：告诉spring是一个定时任务
     * second，minute，hour，day of month，month，day of week
     * 0       *       *     *            *      MON_SAT
     */
//    @Scheduled(cron = "0 * * * * MON-SAT")
//    @Scheduled(cron = "0,1,2,3,4 * * * * MON-SAT")//枚举
//    @Scheduled(cron = "0-2 * * * * MON-SAT")//区间
    @Scheduled(cron = "0/4 * * * * MON-SAT")//从0秒启动每4s启动一次
    public void sayHello(){
        System.out.println(new Date(System.currentTimeMillis()) +"处理数据~");
    }
}
